package com.laiyima.zhongjiang.linghuilv.demo.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.laiyima.zhongjiang.linghuilv.demo.R;
import com.laiyima.zhongjiang.linghuilv.demo.bean.MySelectAgentBean;

import java.util.List;

public class SelectAgentAdapter extends BaseAdapter {
    private Context mContext;
    private LayoutInflater mInflater;
    private List<MySelectAgentBean> mMySelectAgentBean;
    private String TAG="AgentAdapter";
    public SelectAgentAdapter(Context context, List<MySelectAgentBean> maxMySelectAgentBeanDatas){
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mMySelectAgentBean = maxMySelectAgentBeanDatas;
    }
    @Override
    public int getCount() {
        return mMySelectAgentBean.size();
    }

    @Override
    public Object getItem(int position) {
        return mMySelectAgentBean.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null){
            convertView = mInflater.inflate(R.layout.select_agent_item,parent,false);
            viewHolder = new ViewHolder();
            viewHolder.mselectAgent_name = convertView.findViewById(R.id.selsct_name);
            viewHolder.mselectAgent_uid = convertView.findViewById(R.id.select_uid);

            convertView.setTag(viewHolder);

        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        MySelectAgentBean mySelectAgentBean = mMySelectAgentBean.get(position);
        viewHolder.mselectAgent_name.setText(mySelectAgentBean.getAdmin_name());
        viewHolder.mselectAgent_uid.setText(mySelectAgentBean.getUid());
        viewHolder.mselectAgent_uid.setTextColor(Color.parseColor("#FFFFFFFF"));
        return convertView;
    }
    public static class ViewHolder{
        TextView mselectAgent_name;
        TextView mselectAgent_uid;

    }
}
